home *** CD-ROM | disk | FTP | other *** search
/ Champak 141 / (Vol 141) Oct 17 2011.iso / Games / gamma-bros.swf / scripts / __Packages / classes / fx / Shrapnel.as < prev    next >
Encoding:
Text File  |  2011-10-17  |  4.8 KB  |  163 lines

  1. class classes.fx.Shrapnel
  2. {
  3.    var x;
  4.    var y;
  5.    var type;
  6.    var id;
  7.    var special;
  8.    var color;
  9.    var clip;
  10.    var xMov;
  11.    var yMov;
  12.    var cMax;
  13.    var ce;
  14.    var rotateVar;
  15.    var rotateInt;
  16.    var c = 0;
  17.    var smoker = false;
  18.    var yank = false;
  19.    var black = false;
  20.    function Shrapnel(px, py, ptype, pcolor, pspecial, pblack, pid)
  21.    {
  22.       this.x = px;
  23.       this.y = py;
  24.       this.type = ptype;
  25.       this.id = pid;
  26.       this.special = pspecial;
  27.       this.color = pcolor;
  28.       this.black = pblack;
  29.       if(this.special == undefined)
  30.       {
  31.          this.special = false;
  32.       }
  33.       _root.d = _root.d + 1;
  34.       this.clip = _root.attachMovie("shrapnel","shrapnel" + this.id + "Clip",_root.d);
  35.       this.clip._x = this.x;
  36.       this.clip._y = this.y;
  37.       this.xMov = _root.randRange(-5,5);
  38.       this.yMov = _root.randRange(-5,5);
  39.       this.cMax = _root.randRange(50,100);
  40.       if(this.type.charAt(0) != "B")
  41.       {
  42.          var _loc3_ = _root[this.type + "Shrap"].slice();
  43.          var _loc6_ = _loc3_[0];
  44.          var _loc7_ = _loc3_[random(_loc3_.length - 1) + 1];
  45.          if(_loc7_.charAt(0) == "C" && random(2) > 0)
  46.          {
  47.             this.clip.gotoAndPlay(this.type + _loc7_);
  48.             this.smoker = true;
  49.          }
  50.          else
  51.          {
  52.             this.clip.bitColor = _loc7_;
  53.             if(_loc6_ == "light")
  54.             {
  55.                this.clip.gotoAndPlay("generic1");
  56.             }
  57.             else
  58.             {
  59.                this.clip.gotoAndPlay("generic2");
  60.             }
  61.          }
  62.       }
  63.       else
  64.       {
  65.          _loc3_ = _root[this.type + "Shrap"].slice();
  66.          _loc7_ = _loc3_[random(_loc3_.length)];
  67.          this.clip.gotoAndPlay(this.type + _loc7_);
  68.          this.smoker = true;
  69.       }
  70.       if(this.black)
  71.       {
  72.          var _loc4_ = new flash.geom.Transform(this.clip);
  73.          var _loc5_ = new flash.geom.ColorTransform(0,0,0,1,-255,-255,-255,0);
  74.          _loc4_.colorTransform = _loc5_;
  75.       }
  76.       this.ce = _root.randRange(15,150);
  77.       this.rotateVar = random(2) <= 0 ? -1 : 1;
  78.       this.rotateInt = _root.randRange(2,5);
  79.       if(this.smoker)
  80.       {
  81.          this.rotateInt = this.rotateInt + 1;
  82.       }
  83.       if(this.special)
  84.       {
  85.          this.cMax = 1000;
  86.       }
  87.    }
  88.    function main()
  89.    {
  90.       this.c = this.c + 1;
  91.       if(this.c / this.rotateInt == Math.round(this.c / this.rotateInt))
  92.       {
  93.          this.clip._rotation += 90 * this.rotateVar;
  94.       }
  95.       if(this.c >= this.cMax)
  96.       {
  97.          this.yank = true;
  98.       }
  99.       if(this.smoker)
  100.       {
  101.          if(random(10) > 8)
  102.          {
  103.             _root.shrapID = _root.shrapID + 1;
  104.             _root["shipSmoke" + _root.shrapID] = new classes.fx.ShipSmoke(this.x,this.y,_root.shrapID,this.black);
  105.             _root.addFX("shipSmoke" + _root.shrapID);
  106.          }
  107.          if(this.clip.hitTest(_root[_root.char + "Clip"]))
  108.          {
  109.             _root[_root.char].nudge(this.xMov * 1.5,this.yMov * 1.5,this.clip._alpha * 2);
  110.          }
  111.       }
  112.       if(this.c == this.ce)
  113.       {
  114.          if(this.black && this.color == "")
  115.          {
  116.             if(this.special)
  117.             {
  118.                _root.createExploD([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(50,80),90]);
  119.             }
  120.             else
  121.             {
  122.                _root.createExploD([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(30,60),75 - this.c * (100 / this.cMax)]);
  123.             }
  124.          }
  125.          else if(this.special)
  126.          {
  127.             if(this.black)
  128.             {
  129.                var _loc3_ = 0;
  130.                var _loc4_ = _root.randRange(1,3);
  131.                while(_loc3_ < _loc4_)
  132.                {
  133.                   _root.createExploA([this.x + this.clip._width / 2 + _root.randRange(-25,25),this.y + this.clip._height / 2 + _root.randRange(-25,25),_root.randRange(75,150),90,this.color]);
  134.                   _loc3_ = _loc3_ + 1;
  135.                }
  136.             }
  137.             else
  138.             {
  139.                _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(50,80),90,this.color]);
  140.             }
  141.          }
  142.          else
  143.          {
  144.             _root.createExploA([this.x + this.clip._width / 2,this.y + this.clip._height / 2,_root.randRange(30,60),75 - this.c * (100 / this.cMax),this.color]);
  145.          }
  146.          _root.audio.playLevel4("shrapX" + random(5),_root.randRange(5,15));
  147.          this.yank = true;
  148.       }
  149.       if(!this.special)
  150.       {
  151.          this.clip._alpha = 110 - this.c * (110 / this.cMax);
  152.       }
  153.       if(this.yank)
  154.       {
  155.          _root.removeFX("shrapnel" + this.id);
  156.       }
  157.       this.x += this.xMov;
  158.       this.y += this.yMov;
  159.       this.clip._x = this.x;
  160.       this.clip._y = this.y;
  161.    }
  162. }
  163.